package Tree_09.HuffmanCode_06;

/*
 * @Author 罗
 * @date 2020/3/23 - 9:24 上午
 *
 */

import org.junit.Test;

import java.util.Arrays;
import java.util.Map;


public class test {

    public static void main(String[] args) {
        String str = "i like like like java do you like a java";

        byte[] huffmanCodeBytes = HuffmanCode.huffmanZip(str.getBytes());

        System.out.println(Arrays.toString(huffmanCodeBytes));

        Map<Byte,String> huffmanCodeTable = HuffmanCode.getHuffmanCodeTable();

        byte[] bytesData =  HuffmanDecode.huffmanDecode(huffmanCodeTable,huffmanCodeBytes);
        /*
        * 最简单的将字节数组 的数据转为String
        * */
        System.out.println(new String(bytesData));
    }
    public final static String FILE_TO_BE_COMPRESSED_PATH = "/Users/luo/Desktop/壁纸/bg-0cbee9f.jpg";
    public final static String ZIP_FILE_PATH = "/Users/luo/Desktop/图片.zip";
    public final static String DECOMPRESS_FILE_PATH = "/Users/luo/Desktop/解压后的文件.jpg";

    @Test
    public void fileZip(){
        FileZip.fileZip(FILE_TO_BE_COMPRESSED_PATH,ZIP_FILE_PATH);
    }

    @Test
    public void fileDecompression(){
        FileZip.fileDecompression(ZIP_FILE_PATH,DECOMPRESS_FILE_PATH);
    }


}
